import axios from "axios";
import { Message } from 'element-ui';

const service = axios.create({
  timeout: 10000,
});

service.interceptors.response.use((response) => {
  const { data, code, msg } = response.data // 默认json格式
  if (code === 200) {
    return data
  } else {
    Message({ type: 'error', message: msg })
    return
  }
}, async(error) => {
  // error.message
  Message({ type: 'error', message: error.message })
  return Promise.reject(error)
})



export default service;

